﻿namespace FitnessTracker.Calculators
{
    using System;

    public static class TimeOffsetCalculator
    {
        public static double GetTimeDifferenceBetweenEventsInFractionOfSeconds(
            DateTime startEvent,
            DateTime endEvent)
        {
            var eventTimeOffsetInMilliSeconds = endEvent.Subtract(startEvent).Milliseconds;
            var eventTimeOffsetInSeconds = endEvent.Subtract(startEvent).Seconds;
            var eventTimeOffsetInMinutes = endEvent.Subtract(startEvent).Minutes;
            var eventTimeOffsetInHours = endEvent.Subtract(startEvent).Hours;
            var eventTimeOffsetInDays = endEvent.Subtract(startEvent).Days;

            return TimeSpan.FromDays(eventTimeOffsetInDays).TotalSeconds +
                   TimeSpan.FromHours(eventTimeOffsetInHours).TotalSeconds +
                   TimeSpan.FromMinutes(eventTimeOffsetInMinutes).TotalSeconds +
                   eventTimeOffsetInSeconds +
                   TimeSpan.FromMilliseconds(eventTimeOffsetInMilliSeconds).TotalSeconds;
        }
    }
}
